package com.xulu.romance.config;

import com.xulu.romance.handler.InterceptorHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptorHandler())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/api/user/login",
                        "/api/user/front/loginPassword",
                        "/api/user/front/forgetPassword",
                        "/api/user/front/loginCode",
                        "/api/user/register",
                        "/api/user/front/register",
                        "/api/sentence/findById",
                        "/api/question/front/**",
                        "/api/article/front/**",
                        "/api/questionComment/front/**",
                        "/api/articleComment/front/**",
                        "/api/questionType/front/findAll",
                        "/api/questionTag/front/findAll",
                        "/api/articleTag/front/findAll",
                        "/api/mail/front/**",
                        "/error",
                        "/depts/**",
                        "/emps/**",
                        "/favicon.ico",
                        "/**/export",
                        "/**/import",
                        "/api/file/**");
    }

    @Bean
     public InterceptorHandler interceptorHandler(){
        return new InterceptorHandler();
    }
}
